$(function () {
    let data = myAjax("/home", {}, "get");
    console.log(data);
    setNewsData(data.newsModelList);
    setProductData(data.producctModelList);
})



function setNewsData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += '                    <div>\n' +
            '                        <h4>' + data[i].title + '</h4>\n' +
            '                        <p>' + data[i].content + '</p>\n' +
            '                    </div>';
    }
    $("#newsHtml").html(html);
}

function setProductData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {
        if (i == 0) {
            html += ' <div class="floatLeft">';
        } else {
            html += ' <div class="floatRight">';
        }
        html += '<div><img src="../img/48_j53b.jpg" height="300" width="300"/></div>\n' +
            '                        <div>蚂蚁上树</div>\n' +
            '                        <div>粉丝200g,猪内馅50克。</div>\n' +
            '</div>';
    }
    $("#productHtml").html(html);
}